package com.athuahua.spzx.controller;

import com.athuahua.spzx.entity.vo.CategoryVo;
import com.athuahua.spzx.service.CategoryService;
import com.athuahua.spzx.utils.Result;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Author: huahua
 * @Date: 2024/8/9 0009
 * @Time: 17:11
 * @Description:
 */
@Tag(name = "分类接口管理")
@RestController
@RequestMapping("/api/product/category")
@Slf4j
public class CategoryController {
    @Resource
    private CategoryService categoryService;

    //查询所有分类，按照树形封装
    @GetMapping("/findCategoryTree")
    @Cacheable(cacheNames = "c_category_tree")
    public Result findCategoryTree() {
        log.info("查询所有分类，按照树形封装");
        List<CategoryVo> list = categoryService.findCategoryTree();

        return Result.success(list);
    }
}
